<!--
 * @Author: zhangfan
 * @Date: 2024-06-24 11:29:29
 * @LastEditors: ***
 * @LastEditTime: 2024-06-24 14:15:41
 * @Description: 子组件2
 * @FilePath: /demo/src/components/child-two.vue
-->
<template>
  <div class="view-contain-two">
    <p>子组件2</p>
    <p>{{ message }}</p>
  </div>
</template>
<script>
export default {
  data () {
    return {
      message: 456
    }
  },
  created () {
    this.$root.$on('changeChild2Data', data => {
      this.message = data // 更新组件数据
    })
  },
  methods: {
    test () {
      const val = 'i am child-two component'
      return val
    }
  }
}
</script>
<style scoped>
.view-contain-two {
  height: 300px;
  width: 500px;
  border: 1px solid #ccc;
}
</style>
